import request from '../utils/request';

export default {
    // 获取所有用户
    getAll() {
        return request({
            url: `/user/getAll`,
            method: 'get'
        });
    },
    // 获取角色
    getRoles() {
        return request({
            url: `/role/select`,
            method: 'get'
        });
    },
    // 根据教师姓名查询
    getByName(name){
        return request({
            url: `/user/findByName`,
            method: 'get',
            params: {
                name
            }
        });
    },
    addUser(user){
        return request({
            url: `/user/add`,
            method: 'post',
            data: user
        });
    },
    getUserByPage(pageNum,pageSize){
        var param ={
            pageNum: pageNum,
            pageSize: pageSize
        }
        return request({
            url: `/user/selectPage`,
            method: 'post',
            data: param
        });
    },
    getUserById(id){
        return request({
            url: `/user/get/${id}`,
            method: 'get',
        });
    },
    editUser(id,user){
        return request({
            url: `/user/update/${id}`,
            method: 'put',
            data: user
        });
    },
    deleteUser(id){
        return request({
            url: `/user/delete`,
            method: 'delete',
            params: {
                id
            }
        });
    }
}
